﻿@using GoodMan.Infrastructure.Entities.Entity;
@using GoodMan.Infrastructure.Entities.Enum;
@{
    ViewBag.Title = "待处理订单";
    Layout = "~/Areas/WorkSpace/Views/Shared/_StaffTemplete.cshtml";
    ItemListBox<Order> orderList = ViewBag.OrderList;
}

    <link type="text/css" rel="Stylesheet" href="/content/css/select2.css" />
<div id="content-header">
    <h1>待处理订单</h1>
</div>
<div id="breadcrumb">
	<a href="index.html" title="Go to Home" class="tip-bottom"><i class="icon-home"></i>首页</a>
	<a href="/workspace/Staff/OrdersStatistics" class="tip-bottom">订单管理</a>
	<a href="/workspace/Staff/WaitForHandleOrder" class="current">待处理订单</a>
</div>
<div class="container-fluid">
  <div class="row-fluid">
     <div class="span12">
     <div class="widget-box">
			<div class="widget-title">			
				<h5>订单统计</h5>
			</div>
            <form id="frmorderquery" action="/workspace/Staff/WaitForHandleOrder" method="get">
            <div class="control-group">
                <table>
 <tr>                    
                        <td style="width:3%; padding:15px;">订单编号：</td>
                        <td style="width:20%;">
                            <input type="text" name="id" value="@ViewBag.orderCode" style="width:200px; margin-top:10px;"/>
                        </td>
                        <td style="width:3%;">电话：</td>
                        <td style="width:10%;">
                            <input type="text" name="phone" value="@ViewBag.phone" style="width:100px; margin-top:10px;"/>
                        </td>
                        <td style="width:5%;">时间段：</td>
                        <td style="width:26%;">
                            <input id="dtstart" readonly="readonly" name="dtstart" value="@ViewBag.dtstart" type="text" onClick="WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd'})" style="width:100px; margin-top:10px;" class="{dateISO:true}"/> -- 
                            <input id="dtend" readonly="readonly" name="dtend" value="@ViewBag.dtend" type="text" onClick="WdatePicker({skin:'blue',dateFmt:'yyyy-MM-dd'})" style="width:100px; margin-top:10px;" class="{dateISO:true}"/>
                        </td>
                        <td>
                            <button type="submit" class="btn btn-primary">
                                <i class="icon-search icon-white"></i>查询
                            </button>
                        </td>
                    </tr>
                </table>
            </div>
            </form>
			<div class="widget-content nopadding">
				<table class="table table-bordered data-table">
					<thead>
					<tr>
                        <th>订单号</th>
					    <th width="10%">用户名称</th>
                        <th width="10%">电话</th>
					    <th width="7%">价格(积分)</th>
					    <th width="40%">订单内容</th>
                       @* <th width="10%">所属学校</th>
                        <th width="10%">所属楼栋</th>
                        <th width="10%">状态</th>*@
                        <th width="15%">操作</th>
					</tr>
					</thead>
					<tbody>
                    @{
                        if (orderList != null && orderList.Data != null && orderList.Data.Count > 0)
                        {
                            Dormitory dormitoryModel = new Dormitory();
                            foreach (var orderinfo in orderList.Data)
                            {
                                dormitoryModel = new Dormitory().Find(orderinfo.DormitoryID.ToString());
                                <tr class="gradeX">
					                <td><a href="/workspace/Staff/OrderDetail?id=@orderinfo.Id">@orderinfo.OrderCode</a></td>
					                <td><span title="@orderinfo.UserRealName">@orderinfo.UserRealName</span></td>
                                    <td><span title="@orderinfo.Phone">@orderinfo.Phone</span></td>
					                <td>
                                    @if (orderinfo.AreaCode == AreaCode.Integration)
                                    {
                                        <span>@(orderinfo.TotalPrice*GoodMan.Tool.Configration.SiteResource.CostRank)</span>
                                    }
                                    else
                                    {
                                        <span>@orderinfo.TotalPrice</span>
                                    }
                                    </td>
                                    <td>
                                        商品名称：@orderinfo.ProductDescript <br />
                                        下单时间：@orderinfo.OrderDate.ToString("yyyy-MM-dd HH:mm")<br />
                                        商品类型：
                                        @if(orderinfo.AreaCode == AreaCode.Integration)
                                        {
                                            <span class="label label-success">@orderinfo.AreaCode.Mapping() </span>
                                        }
                                        else
                                        {
                                            <span class="label label-important">@orderinfo.AreaCode.Mapping()</span>
                                        }<br />
                                        订单状态：
                                        @if (orderinfo.Status == OrderStatus.WaitForDeliver)
                                        {
                                            <span class="label label-warning">@orderinfo.Status.Mapping()</span>
                                        }
                                        else
                                        {
                                            <span class="label label-info">@orderinfo.Status.Mapping()</span>
                                        }<br />
                                        配送信息：@orderinfo.AssemblingInfo
                                    </td>
                                    @*<td>重庆工商大学</td>
                                    <td><span title="@dormitoryModel.Name">@dormitoryModel.Name</span></td>
					                <td><span title="@orderinfo.Status.Mapping()">@orderinfo.Status.Mapping()</span></td>*@
                                    <td class="center">
                                    @{
                                        if (orderinfo.Status == OrderStatus.WaitForDeliver)
                                        {
                                        <a href="/Staff/ModifyOrder?id=@orderinfo.Id&status=4&page=@orderList.CurrentPage" class="btn btn-primary btn-mini">交易完成</a>
                                        <a href="/Staff/ModifyOrder?id=@orderinfo.Id&status=5&page=@orderList.CurrentPage" onclick="if (confirm('请确认【取消交易】操作前已跟该订单用户进行沟通！')==true){return true;}else{return false;}" class="btn btn-primary btn-mini">取消交易</a>
                                        }
                                        else
                                        {<span>--</span>}
                                        }
                                    
                                    </td>
					            </tr>
                            }
                        }
                        else
                        {
                            <tr class="gradeX"><td colspan="12" align="center">没有找到任何数据！</td></tr>
                        }
                    }			 
					</tbody>
			    </table>  
			</div>
            @Html.Raw(orderList.PageItemSegment)  
		</div>
     </div>
  </div>
  @{
      if (ViewBag.isSuccess != null)
      {
          if (ViewBag.isSuccess)
          { 
                <div class="Success">操作成功！</div>
          }
          else
          {
                <div class="Error">操作失败！</div>
          }
      }
    }
</div>

@section tail{
<script type="text/javascript" src="/Scripts/jquery.validate.js"></script>
<script type="text/javascript" src="/Scripts/jquery.metadata.js"></script>
<script type="text/javascript" src="/Scripts/messages_cn.js"></script>
<script type="text/javascript" src="/Scripts/plug.js"></script>
    <script type="text/javascript" src="/scripts/select2.min.js"></script>

<script type="text/javascript">
    $(function () {
        $('#likOrder').addClass('open');

        $('#likOrder').addClass('active');
        $('#status').each(function () {
            $(this).select2();
        });

        window.setInterval(function () {
            window.location.href = window.location.href;
        }, 10000);
    });
</script>

}

